#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1010, mod = 1e9 + 7;

int n, m;
int f[N], cnt[N];

int main() {
    cin >> n >> m;
    
    for (int i = 0; i < m; ++ i) cnt[i] = 1;
    
    while (n -- ) {
        int v, w;
        cin >> v >> w;
        
        for (int j = m; j >= v; -- j) {
            if (f[j - v] + w > f[j]) f[j] = f[j - v] + w, cnt[j] = cnt[j - v];
            else if (f[j - v] + w == f[j]) cnt[j] = (cnt[j] + cnt[j - v]) % mod;
        }
    }
    
    cout << cnt[m] << endl;
    
    return 0;
}